home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / misc / vpan100.zip / VPBUTT.H < prev    next >
C/C++ Source or Header  |  1995-01-18  |  7KB  |  262 lines

  1. //
  2. //  VIRTUAL PANELS * GRAPHIC USER UNTERFACE FOR LABORATORY WORKS
  3. //
  4. //        VPBUTT.H : CLASSes: tabstop, butgrp,
  5. //                    button,  indbutton
  6. //                    butsystem
  7. //
  8. //                       |     Written by O.Rasizade
  9. //    declarations       |       Sept 1992, 1993
  10. //                       |
  11. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12.  
  13. #ifndef __cplusplus
  14. #error Must use C++ 
  15. #endif
  16.  
  17. #ifndef __VPBUTT_H
  18. #define __VPBUTT_H
  19.  
  20. #if !defined(__VPLED_H)
  21. #include <vpled.h>
  22. #endif
  23.  
  24. #define MASTER        1    // master of Dragging Area
  25.  
  26. // MESSAGES ADDRESSED TO KbdLoop(). Default is 0 no message
  27. #define MSG_EXIT    1
  28. #define MSG_NEXTTABSTOP    2
  29. #define MSG_PREVTABSTOP    3
  30.  
  31. class button;
  32.  
  33. //++++++++++++++++++++++++++++++++++++++++++++++
  34. //++++++     COLORS   ++++++++++++++++++++++++++
  35. //++++++++++++++++++++++++++++++++++++++++++++++
  36.  
  37. //--------------------- FOR BUTTON -----
  38.  
  39. struct buttoncolors {COLORS
  40.             disabledtext,
  41.             hldisabltext,    // color of highlighted disabled text
  42.             enabledtext,
  43.             activetext;
  44.               };
  45. //------------------------------ Default button colors
  46. const buttoncolors buttextdflt={
  47.                   BLACK,
  48.                   LIGHTGRAY,
  49.                   GREEN,
  50.                   LIGHTGREEN
  51.                   };
  52. const plaquecolors butcoldflt={
  53.               DARKGRAY,
  54.               BLACK,
  55.               LIGHTGRAY
  56.               };
  57. //------------------------------ Quit button colors
  58. const buttoncolors quittexcol={
  59.             BLACK,        // disabled text
  60.             DARKGRAY,    // ighlighted disabled text
  61.             LIGHTGRAY,    // enabled text
  62.             WHITE        // active text
  63.               };
  64.  
  65. const plaquecolors quitbutcol={
  66.              RED,        // PlaqeColor
  67.              BLACK,        // shadow
  68.              LIGHTGRAY    // ltnd
  69.             };
  70.  
  71. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  72. //++++++++++++++ CLASS   << tabstop >>  +++++++++++++++++++++
  73. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  74. class tabstop
  75. {
  76. friend butsystem;
  77.  
  78. protected:
  79.  
  80.  tabstop *prev,*next;
  81.  
  82. public:
  83.   tabstop(void);
  84.  
  85.  virtual void  Deactivate(void)=0;
  86.  virtual void  Activate(void)=0;
  87. };
  88.  
  89. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  90. //++++++++++++++ CLASS   << BUTGRP >>  ++++++++++++++++++++++
  91. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  92.  
  93. class butgrp: public tabstop
  94. {
  95.  friend button;
  96.  friend indbutton;
  97.  
  98.  static int x0,y0;    // start point for buttons, incremented by Paint routines
  99.      int direction;     // may be VERT or HORIZ
  100.      int distance;          // between buttons
  101.      int xlen,ylen;
  102.      button *actbut,*fstbut;
  103.  static butgrp *actgrp;
  104.  
  105.  virtual void  Deactivate(void);
  106.  virtual void  Activate(void);
  107.  
  108.  public:
  109.  
  110.  butgrp(int _x0,int _y0,int _xlen,int _ylen,
  111.                     int _direction=HORIZ,int _distance=0);
  112.     void  Paint(void); // paint whole group of buttons
  113.  
  114.     void  ShiftToX(int x) {x0=x;}
  115.     void  ShiftToY(int y) {y0=y;}
  116.     void  ShiftX(int x) {x0+=x;}
  117.     void  ShiftY(int y) {y0+=y;}
  118. };
  119.  
  120. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  121. //++++++++++++++ CLASS   << BUTTON >>  ++++++++++++++++++++++
  122. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  123.  
  124. class button : public plaque
  125. {
  126.  friend butgrp;
  127.  friend butsystem;
  128.  friend indbutton;
  129.  
  130.  char *title;
  131.  int titlefont,titlefontsize;
  132.  void (far *proc)(void);// procedure attached to button
  133.  char asc0,asc1;    // key - extended ASCII of kbd shortcut
  134.  int status;// can be CRL_ACTIVE, CRL_ENABLED, CRL_DISABLED or CRL_HLDISABLED
  135.  buttoncolors buttextcolors;
  136.  
  137.   button *bnext;  // used to make list
  138.   button *bprev;
  139.  
  140.     void  printext(void);
  141.     void  Activate(void);
  142.     void  Deactivate(void);
  143.     void  Press(void);
  144.     void  Release(void);
  145.  
  146. public:
  147.  
  148.  int x0,y0,xmax,ymax;    // location of button
  149.  int xx0,yy0,xxmax,yymax;// versatile location of button
  150.  
  151. //------------ Constructor  ALL SIZES IN VGA PIXELS ------------
  152.  
  153. button (
  154.         char *_title,               // text on button
  155.         char ascii0,char ascii1,    // kbd shortcut to activate button
  156.         void (far *procedure)(void),// procedure connected with button
  157.         int txfont=0,int txsize=1,  // font style and size of text
  158.         buttoncolors buttextcnfg=buttextdflt, //colors of textl
  159.         plaquecolors butcol=butcoldflt);      //colors of button
  160.  
  161.     void  Enable(void)
  162.             { status=CRL_ENABLED;}
  163.     void  Disable(void)
  164.              { status=CRL_DISABLED;}
  165.     int   GetStatus(void)
  166.             { return status; }
  167.  
  168. virtual    void  Paint(void);
  169. };
  170.  
  171. //++++++++++++++ END of class BUTTON +++++++++++++++++++++
  172.  
  173.  
  174. //+++++++++++++++++++++++++++++++++++++++++++++++++
  175. //++++++++++ CLASS   << INDBUTTON >>  +++++++++++++
  176. //+++++++++++++++++++++++++++++++++++++++++++++++++
  177.  
  178. #define INDOFFSET  5
  179.  
  180. //--------------------- Class declaration  --
  181.  
  182. class indbutton: public button, public LED
  183. {
  184.  
  185. public:
  186.  
  187.   //----- Constructor ------- All coord. and sizes in VGA pixels ----
  188.  indbutton(
  189.         char *_title,               // text on button
  190.         char ascii0,char ascii1,    // kbd shortcut to activate button
  191.         void (far *procedure)(void),    // procedure connected with button
  192.             // Hereafter are defaults
  193.         int _indradius=4,        // radius of indicator
  194.         int txfont=0,int txsize=1,  // font style and size of text
  195.         LEDcolors _indcol=redLED,    //colors of LED
  196.         buttoncolors buttextcnfg=buttextdflt,    //colors of textl
  197.         plaquecolors butcol=butcoldflt        //colors of button
  198.         );
  199.  
  200. virtual    void  Paint(void);
  201.  
  202. };//++++++++++++++ END of class indbutton +++++++++++++++++++
  203.  
  204.  
  205. //+++++++++++++++++++++++++++++++++++++++++++++++++
  206. //++++++++++ CLASS   << BUTSYSTEM >>  +++++++++++++
  207. //+++++++++++++++++++++++++++++++++++++++++++++++++
  208.  
  209. //--------------------- Class declaration  --
  210.  
  211. class butsystem
  212. {
  213. friend tabstop;
  214. friend butgrp;
  215. friend button;
  216. friend indbutton;
  217.  
  218.  
  219.  static butsystem *actbutsys;
  220.  
  221.    butsystem *oldbutsys;    // storage
  222.    int master;        // if TRUE then is the master of Dragging Area
  223.    int butstatus;    // status of button system:
  224.             //   if 0 then button system is not installed
  225.             //      1 then button system has been installed
  226.    tabstop *actgrp;    // ptr to active tabstop
  227.    tabstop *fstgrp;    //        first  tabstop
  228.  
  229.    button *actbut;    // ptr to active button
  230.    button *fstbut;     //        first button
  231.  
  232.    int      message;    // message box for KbdLoop
  233.  
  234. void  Process(void);
  235.  
  236. public:
  237.  
  238.  unsigned int   ConStatus;    // status of kbd and mouse
  239.  unsigned char  key0;        // ascii codes of last keystroke
  240.  unsigned char  key1;
  241.  
  242.   //----- Constructor
  243.  butsystem(int _master = 0); // Is not master by default
  244.  
  245.  //------ Destructor
  246.  ~butsystem(void)
  247. {
  248.  actbutsys = oldbutsys;
  249. }
  250.  
  251. static void  SendMessage( int messg); // to Loop()
  252.  
  253.  void  NextTabStop(void);    // Increase active tabstop
  254.  void  PrevTabStop(void);    // Decrease active tabstop
  255.  void  NextButton(void);    // Increase active button
  256.  void  PrevButton(void);    // Decrease active button
  257.  void  Loop(void (far *bkgrproc)(void));
  258.  
  259. };//++++++++++++++ END of class butsystem+++++++++++++++++++
  260.  
  261.  
  262. #endif // __VPBUTT_H